package com.micro.trace.log;

import com.micro.trace.log.filter.TraceLogFilter;
import com.micro.trace.log.handler.PerceptionHandlerExceptionResolver;
import com.micro.trace.log.handler.PerceptionHandlerInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.HandlerInterceptor;


@Configuration
@ConditionalOnClass(name = "org.springframework.web.servlet.DispatcherServlet")
public class TraceLogAutoConfiguration {

    @Bean("x-trace-log-filter")
    public TraceLogFilter traceLogFilter() {
        return new TraceLogFilter();
    }

    @Bean
    public HandlerExceptionResolver perceptionHandlerExceptionResolver() {
        return new PerceptionHandlerExceptionResolver();
    }

    @Bean
    public HandlerInterceptor perceptionHandlerInterceptor() {
        return new PerceptionHandlerInterceptor();
    }


}
